#include "WiFly.h"

Server server(2000);

void setup() {
  
  Serial.begin(9600);
  
  WiFly.begin();
  Serial.println(WiFly.ip());
  server.begin();
  

  Serial.println("Setup completed");
}

boolean loopMessageOnce;

void loop()
{
  if(!loopMessageOnce){
    Serial.println("Loop commenced");
    loopMessageOnce = true;
  }
  
  Client client = server.available();
  Serial.print((long unsigned int) client);
    
  if(client != 0){
    Serial.println("Client connected");
    
    while(client.connected()){
      client.print("1,2,3,4,5,6,7,8\r\n");
      Serial.print((long unsigned int) server.available());
      delay(1000);
      
      if(server.available() == 0){
        break;
      }
    }
    
    client.stop();
    Serial.print("x");
  }
  
  Serial.print(".");
  delay(1000);
}
